home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / WASTE 1.0a4 Distribution / WASTE Headers / C Interfaces / WASTE.h < prev   
Text File  |  1994-03-28  |  7KB  |  238 lines

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C interface to the WASTE text engine
  5.  *    version 1.0a3 -- March/April 1994
  6.  *
  7.  *    Copyright (c) 1993-1994 Merzwaren
  8.  *    All Rights Reserved
  9.  */
  10.  
  11. #ifndef _WASTE_
  12. #define _WASTE_
  13.  
  14. #ifndef _LongCoords_
  15. #include "LongCoords.h"
  16. #endif
  17.  
  18. #ifndef __TEXTEDIT__
  19. #include <TextEdit.h>
  20. #endif
  21.  
  22. /*    alignment styles */
  23.  
  24. enum {
  25.     weFlushLeft         =    -2,        /* flush left */
  26.     weFlushRight        =    -1,        /* flush right */
  27.     weFlushDefault        =     0,        /* flush according to system direction */
  28.     weCenter            =     1,        /* centered */
  29.     weJustify            =     2        /* fully justified */
  30. };
  31.  
  32. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  33.  
  34. enum {
  35.     weDoFont            =    0x0001,
  36.     weDoFace            =    0x0002,
  37.     weDoSize            =    0x0004,
  38.     weDoColor            =    0x0008,
  39.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  40.     weDoAddSize            =    0x0010,
  41.     weDoToggleFace        =    0x0020,
  42.     weDoReplaceFace        =    0x0040
  43. };
  44.  
  45. /*    values for the edge parameter in WEGetOffset etc. */
  46.  
  47. enum {
  48.     kLeadingEdge = -1,
  49.     kTrailingEdge = 0
  50. };
  51.  
  52. /*    values for WEFeatureFlag feature parameter */
  53.  
  54. enum {
  55.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  56.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  57.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  58.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  59.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  60. };
  61.  
  62. /*    values for WENew flags parameter */
  63.  
  64. enum {
  65.     weDoAutoScroll        =    1 << weFAutoScroll,
  66.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  67.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  68.     weDoUseTempMem        =    1 << weFUseTempMem,
  69.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  70. };
  71.  
  72. /*    values for WEFeatureFlag action parameter */
  73.  
  74. enum {
  75.     weBitTest = -1,                /* return the current setting of the specified feature */
  76.     weBitClear,                    /* disables the specified feature */
  77.     weBitSet                    /* enables the specified feature */
  78. };
  79.  
  80. /*    selectors for WEGetInfo and WESetInfo */
  81.  
  82. enum {
  83.     weClickLoop        =    'clik',        /* click loop callback */
  84.     wePort            =    'port',        /* graphics port */
  85.     weRefCon        =    'refc',        /* reference constant for use by application */
  86.     weScrollProc    =    'scrl',        /* auto-scroll callback */
  87.     weText            =    'text',        /* text handle */
  88.     weTSMDocumentID    =    'tsmd',        /* Text Services Manager document ID */
  89.     weTSMPreUpdate    =    'pre ',        /* Text Services Manager pre-update callback */
  90.     weTSMPostUpdate    =    'post'        /* Text Services Manager post-update callback */
  91. };
  92.  
  93. typedef struct WERunInfo {
  94.     long         runStart;
  95.     long         runEnd;
  96.     short         runHeight;
  97.     short         runAscent;
  98.     TextStyle     runStyle;
  99. } WERunInfo;
  100.  
  101. typedef Handle WEHandle;
  102.  
  103. /*    callback prototypes */
  104.  
  105. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  106. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  107. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  108. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  109.         long fixLength, long inputAreaStart, long inputAreaEnd,
  110.         long pinRangeStart, long pinRangeEnd);
  111.  
  112. /*    WASTE public calls */
  113.  
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117.  
  118. /*    creation and destruction */
  119.  
  120. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
  121. pascal void WEDispose(WEHandle hWE);
  122.  
  123. /*    getting variables */
  124.  
  125. pascal Handle WEGetText(WEHandle hWE);
  126. pascal short WEGetChar(long offset, WEHandle hWE);
  127. pascal long WEGetTextLength(WEHandle hWE);
  128. pascal long WECountLines(WEHandle hWE);
  129. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  130. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  131. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  132. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  133. pascal Boolean WEIsActive(WEHandle hWE);
  134.  
  135. /*    setting variables */
  136.  
  137. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  138. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  139. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  140.  
  141. /*    accessing style run information */
  142.  
  143. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
  144. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
  145.  
  146. /*    converting byte offsets to screen position and vice versa */
  147.  
  148. pascal long WEGetOffset(const LongPoint *thePoint, char *edge, WEHandle hWE);
  149. pascal void WEGetPoint(long offset, LongPoint *thePoint, short *lineHeight, WEHandle hWE);
  150.  
  151. /*    finding words and lines */
  152.  
  153. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  154. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  155.  
  156. /*    making a copy of a text range */
  157.  
  158. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WEHandle hWE);
  159.  
  160. /*    getting and setting the alignment style */
  161.  
  162. pascal char WEGetAlignment(WEHandle hWE);
  163. pascal void WESetAlignment(char alignment, WEHandle hWE);
  164.  
  165. /*    recalculating line breaks, drawing and scrolling */
  166.  
  167. pascal OSErr WECalText(WEHandle hWE);
  168. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  169. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  170. pascal void WESelView(WEHandle hWE);
  171.  
  172. /*    handling activate / deactivate events */
  173.  
  174. pascal void WEActivate(WEHandle hWE);
  175. pascal void WEDeactivate(WEHandle hWE);
  176.  
  177. /*     handling key-down events */
  178.  
  179. pascal void WEKey(short key, short modifiers, WEHandle hWE);
  180.  
  181. /*    handling mouse-down events and mouse tracking */
  182.  
  183. pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
  184.  
  185. /*    adjusting the cursor shape */
  186.  
  187. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  188.  
  189. /*    blinking the caret */
  190.  
  191. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  192.  
  193. /*    modifying the text and the styles */
  194.  
  195. pascal OSErr WEInsert(const void *textPtr, long textLength, StScrpHandle hStyles, WEHandle hWE);
  196. pascal OSErr WEDelete(WEHandle hWE);
  197. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
  198. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  199. pascal OSErr WEUseText(Handle hText, WEHandle hWE);
  200.  
  201. /*    clipboard operations */
  202.  
  203. pascal OSErr WECut(WEHandle hWE);
  204. pascal OSErr WECopy(WEHandle hWE);
  205. pascal OSErr WEPaste(WEHandle hWE);
  206.  
  207. /*    Script Manager utilities */
  208.  
  209. pascal short WECharByte(long offset, WEHandle hWE);
  210. pascal short WECharType(long offset, WEHandle hWE);
  211.  
  212. /*    Text Services Manager support */
  213.  
  214. pascal OSErr WEInstallTSMHandlers(void);
  215. pascal void WEStopInlineSession(WEHandle hWE);
  216.  
  217. /*    additional features */
  218.  
  219. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  220. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  221. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  222.  
  223. /*    long coordinate utilities */
  224.  
  225. pascal void WELongPointToPoint(const LongPoint *lp, Point *p);
  226. pascal void WEPointToLongPoint(Point p, LongPoint *lp);
  227. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  228. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  229. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  230. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  231. pascal Boolean WELongPointInLongRect(const LongPoint *lp, const LongRect *lr);
  232.  
  233. #ifdef __cplusplus
  234. }
  235. #endif
  236.  
  237. #endif _WASTE_
  238.